package com.gg.api.msm.mqListener;

import com.gg.api.msm.service.MessageApiService;
import com.gg.registration.rabbitmq.constant.MQConstant;
import com.gg.registration.vo.msm.MsmVo;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * MQ 监听器
 * Author：  chenjunjia
 * Date：    2022/4/25 17:20
 * WeChat：  China_JoJo_
 */

/**
 * 这个监听器存在一个反序列化的问题，之后处理一下
 */
@Component
public class SMSListener {

    @Resource
    private MessageApiService messageApiService;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = MQConstant.QUEUE_MSM_ITEM, durable = "true"),
            exchange = @Exchange(value = MQConstant.EXCHANGE_DIRECT_MSM),
            key = {MQConstant.ROUTING_MSM_ITEM}
    ))
    public void send(HashMap smsMap, Message message, Channel channel) {

        messageApiService.send(smsMap);
    }
}
